const cloudbase = require('@cloudbase/node-sdk');

exports.main = async (event, context) => {
    const app = cloudbase.init({
        env: cloudbase.getCloudbaseContext().ENV_ID
    });

    const db = app.database();

    try {
        // 查询bubble_tags集合中的所有文档
        const res = await db.collection('bubble_tags').get();

        return {
            code: 0,
            message: 'success',
            data: res.data
        };
    } catch (error) {
        console.error('获取bubble_tags失败:', error);
        return {
            code: -1,
            message: error.message,
            data: null
        };
    }
};